<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <div id="app"></div>
  
  <script src="../react-js/react.development.js" crossorigin></script>
  <script src="../react-js/react-dom.development.js" crossorigin></script>
  <script src="../react-js/babel.min.js"></script>

  <script type="text/babel">
    function getSizeImage(img, size) {
      // return img + `?param=${size}x${size}`
      console.log(img, size);
      return img
    }


    class App extends React.Component {
      constructor() {
        super()

        this.state = {
          message: 'Hello React ！',
          title: '我是元素的title属性',
          imgUrl: 'https://img2.baidu.com/it/u=2761172546,703993417&fm=26&fmt=auto',
          active: true,
          backgroundColor: 'pink'
        }
      }

      render() {
        const { title, message, imgUrl, active, backgroundColor } = this.state

        return (
          <div>
            {/*1. 绑定属性*/}
            <h2 title={ title }>{ message }</h2>
            <img src={ getSizeImage(imgUrl, 90) } alt="" />
            
            {/*2. 绑定clss*/}
            <div className="box">标签</div>
            <div className={"box " + (active ? 'active' : '') }>标签 动态加class</div>

            {/*3. 绑定style*/}
            <div style={{color: 'red', background: backgroundColor, fontSize: '30px' }}>加内联样式</div>
          </div>
        )
      }
    }

    ReactDOM.render(<App/>, document.getElementById('app'))
  </script>
  
</body>
</html>